package com.cmwa.scbp.sys.schedule.quartz;


import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cmwa.scbp.sys.msg.vo.MsgConfVo;

@DisallowConcurrentExecution
public class QuartzJobMsgBasic implements Job{

	private static Logger logger = LoggerFactory.getLogger(QuartzJobMsgBasic.class);

	private static final String SUCCESS = "执行成功!";
	private static final String ERROR = "执行失败!";
	
	@Override
	public void execute(JobExecutionContext context)
			throws JobExecutionException {

		String result = SUCCESS;
		String jobId = null;
		try {
			MsgConfVo scheduleJob = (MsgConfVo) context.getMergedJobDataMap().get(LoadMsgBacklogMonitorJob.JOB_DATA_MAP_KEY_DEFAULT);
			jobId = scheduleJob.getId();
			if(scheduleJob.getSendType().equals("Backlog")){
				//MsgBacklogCached.getBacklog(scheduleJob);
			}else{
				//MsgMonitorCached.getMonitor(scheduleJob);
			}
		
		} catch (Exception e) {
			result = ERROR;
			String errmsg=e.getCause().getMessage();
			if (errmsg !=null && errmsg.length() > 50) {
				result +=errmsg.substring(0,50);
			}else if(errmsg !=null ){
				result +=errmsg;
			}
			logger.error("QuartzJobMsgBasic error:", e);
			e.printStackTrace();
		} finally {
			logger.debug("QuartzJobMsgBasic"+result+":"+jobId);
		}
	}

}
